﻿/**********************************弘石
*******************************************
* 功能描述:考勤管理（考勤申请管理）
* 作者:李兰祥
* 时间:2021‎年‎12‎月‎10‎日
* 
**********************************弘石
********************************************/
using HongStone.API.Helper;
using HongStone.Domain.AttendanceManagement;
using HongStone.Ince;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

/// <summary>
/// 考勤管理控制器
/// </summary>
namespace HongStone.API.Controllers
{
    [ApiExplorerSettings(GroupName = "Attendance")]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AttendanceController : ControllerBase
    {
        private readonly AttendanceInce _app;
        private readonly JwtHelpers _add;
        public AttendanceController(AttendanceInce app, JwtHelpers add)
        {
            _add = add;
            _app = app;
        }

        /// <summary>
        /// 添加申请(请假)
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult AddClocking_inApplyFo(Clocking_inApplyFo model)
        {
            return Ok(_app.AddClocking_inApplyFo(model));
        }

        /// <summary>
        /// 显示待审批状态
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetClocking_inApplyFo()
        {
            return Ok(_app.GetClocking_inApplyFo());
        }

        /// <summary>
        ///获取数据
        /// </summary>
        /// <param name="ApplyForId"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult EditClocking_inApplyFo(int ApplyForId)
        {
            return Ok(_app.EditClocking_inApplyFo(ApplyForId));
        }

        /// <summary>
        /// 请假申请列表
        /// </summary>
        /// <param name="ApplyName"></param>
        /// <param name="ShiJian"></param>
        /// <param name="Clocking_inState"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetQing(string ZhuangTai, string ApplyName, string ShiJian, string Clocking_inState, int pageIndex=1, int pageSize=2, int ApplyForTpe=1)
        {
            var totalCount = 0;

            var list = _app.GetQing(ApplyName, ShiJian, Clocking_inState, pageIndex, pageSize, out totalCount,ZhuangTai,ApplyForTpe);

            return Ok(new { totalCount, list });
        }

        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdateQing01(int ApplyForId)
        {
            return Ok(_app.UpdateQing01(ApplyForId));
        }

        /// <summary>
        /// 修改状态（请假申请）
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdateQing02(int ApplyForId)
        {
            return Ok(_app.UpdateQing02(ApplyForId));
        }

        /// <summary>
        /// 批量删除（请假申请）
        /// </summary>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult DeleteQing(string ids)
        {
            return Ok(_app.DeleteQing(ids));
        }

        /// <summary>
        /// 反填（请假管理）
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult EditQing(int ApplyForId)
        {
            return Ok(_app.EditQing(ApplyForId));
        }

        /// <summary>
        /// 请假修改
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public IActionResult UpdateQing(Clocking_inApplyFo model)
        {
            return Ok(_app.UpdateQing(model));
        }
    }
}
